package com.neusoft.nepm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neusoft.nepm.mapper.GridCityMapper;
import com.neusoft.nepm.po.GridCity;
import com.neusoft.nepm.service.IGridCityService;
import com.neusoft.nepm.vo.ResponseData;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zouran
 * createDate：2023/6/19  14:40
 */
@Service
public class GridCityServiceImpl implements IGridCityService {
    @Resource
    private GridCityMapper mapper;
    /**
     * 根据省份id查询市列表
     * @param provinceId
     * @return
     */
    @Override
    public ResponseData<List<GridCity>> listGridCityByProvinceId(Integer provinceId) {
        ResponseData data = new ResponseData<>();
        if(provinceId==null){
            data.setCode(1001);
            data.setMessage("省份id为空");
            return data;
        }
        QueryWrapper<GridCity> qw = new QueryWrapper<>();
        qw.eq("province_id", provinceId);
        List<GridCity> list = mapper.selectList(qw);
        if(list==null){
            data.setCode(2001);
            data.setMessage("数据库查询市失败");
            return data;
        }
        //正常业务
        data.setCode(200);
        data.setMessage("success");
        data.setResult(list);
        return data;
    }
}
